#include <pic16f913.h>

//-------------------EEProm used------------------------------------------------

bit blGIEBackup = 0;


/*
void fnEEPromInitWrite(void)
{
	fnEEProm_Write(ADDR_FLAG_INITIALED,0x55);
}


void fnEEPromInitRead(void)
{
}
*/

void fnEEProm_Write(unsigned char bAddr,unsigned char bVal)
{
	EEADRL = bAddr;
	EEDATL = bVal;
	EEPGD = 0;
	WREN = 1;
	blGIEBackup = GIE;
	GIE = 0;
	EECON2 = 0x55;
	EECON2 = 0xAA;
	WR = 1;
	WREN = 0;
	while(WR);
	GIE = blGIEBackup;
}

unsigned char fnEEProm_Read(unsigned char bAddr)
{
	unsigned char bVal;
	EEADRL = bAddr;
//	EECON1.EEPGD = 0;
//	EECON1.RD = 1;
	EEPGD = 0;
	RD = 1;
	bVal = EEDATL;
	return bVal;
}
